<?php /* SVN: $Id: $ */ ?>
<div class="affiliateRequests index">
<div class="clearfix">
<ul class="filter-list-block clearfix">
        <li <?php if (!isset($this->request->params['named']['main_filter_id'])) { echo 'class="active"';} ?>><span class="lightblue-block" title="<?php echo __l('Pending'); ?>"><?php echo $this->Html->link($this->Html->cInt($waiting_for_approval,false).'<span>' .__l('Pending'). '</span>', array('controller'=>'affiliate_requests','action'=>'index','main_filter_id' => ConstAffiliateRequests::Pending), array('escape' => false));?></span> </li>
        <li <?php if (!empty($this->request->params['named']['main_filter_id']) && $this->request->params['named']['main_filter_id'] == ConstAffiliateRequests::Accepted) { echo 'class="active"';} ?>><span class="green-block" title="<?php echo __l('Approved'); ?>"><?php echo $this->Html->link($this->Html->cInt($approved,false).'<span>' .__l('Approved'). '</span>', array('controller'=>'affiliate_requests','action'=>'index','main_filter_id' => ConstAffiliateRequests::Accepted), array('escape' => false));?></span> </li>
        <li <?php if (!empty($this->request->params['named']['main_filter_id']) && $this->request->params['named']['main_filter_id'] == ConstAffiliateRequests::Rejected) { echo 'class="active"';} ?>><span class="brown-block" title="<?php echo __l('Rejected'); ?>"><?php echo $this->Html->link($this->Html->cInt($rejected,false).'<span>' .__l('Rejected'). '</span>', array('controller'=>'affiliate_requests','action'=>'index','main_filter_id' => ConstAffiliateRequests::Rejected), array('escape' => false));?></span> </li>
        <li <?php if (empty($this->request->params['named']['main_filter_id'])) { echo 'class="active"';} ?>><span class="import-block" title="<?php echo __l('Completed'); ?>"><?php echo $this->Html->link($this->Html->cInt($all,false).'<span>' .__l('All'). '</span>', array('controller'=>'affiliate_requests','action'=>'index'), array('escape' => false));?></span> </li>
</ul>
</div>

<div class="page-count-block clearfix">
	<div class="grid_left">
<?php echo $this->element('paging_counter');?>
</div>
<div class="grid_left">
<?php echo $this->Form->create('AffiliateRequest', array('type' => 'get', 'class' => 'normal search-form', 'action'=>'index')); ?>
            <?php echo $this->Form->input('q', array('label' => __l('Keyword'))); ?>
			<?php echo $this->Form->submit(__l('Search'));?>
	<?php echo $this->Form->end(); ?>
	</div>
<div class="add-block add-block clearfix grid_right">
	<?php echo $this->Html->link(__l('Add'), array('controller' => 'affiliate_requests', 'action' => 'add'), array('class' => 'add', 'title'=>__l('Add'))); ?>
</div>
</div>
<?php echo $this->Form->create('AffiliateRequest' , array('class' => 'normal','action' => 'update')); ?>
<?php echo $this->Form->input('r', array('type' => 'hidden', 'value' => $this->request->url)); ?>

<table class="list">
    <tr>
        <th class="select"><?php echo __l('Select');?></th>
        <th class="actions"><?php echo __l('Actions');?></th>
        <th class="dl"><?php echo $this->Paginator->sort(__l('User'), 'User.username');?></th>
        <th class="dl"><?php echo $this->Paginator->sort(__l('Site'), 'site_name');?></th>
        <th class="dl"><?php echo $this->Paginator->sort(__l('Site URL'), 'site_url');?></th>
        <th class="dl"><?php echo $this->Paginator->sort(__l('Site Category'), 'site_category_id');?></th>
        <th class="dl"><?php echo $this->Paginator->sort(__l('Why Do You Want Affiliate'), 'why_do_you_want_affiliate');?></th>
        <th class="dc"><?php echo $this->Paginator->sort(__l('Website Marketing?'), 'is_web_site_marketing');?></th>
        <th class="dc"><?php echo $this->Paginator->sort(__l('Search Engine Marketing?'),'is_search_engine_marketing');?></th>
        <th class="dc"><?php echo $this->Paginator->sort(__l('Email Marketing'),'is_email_marketing');?></th>
         <th class="dl"><?php echo $this->Paginator->sort(__l('Promotional Method'),'special_promotional_method');?></th>
        <th class="dc"><?php echo $this->Paginator->sort(__l('Approved?'),'is_approved');?></th>
    </tr>
<?php
if (!empty($affiliateRequests)):

$i = 0;
foreach ($affiliateRequests as $affiliateRequest):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	if($affiliateRequest['AffiliateRequest']['is_approved']):
		$status_class = 'js-checkbox-active';
	else:
		$status_class = 'js-checkbox-inactive';
	endif;
	
	
	}
?>
	<tr<?php echo $class;?>>
         <td class="select"><?php echo $this->Form->input('AffiliateRequest.'.$affiliateRequest['AffiliateRequest']['id'].'.id', array('type' => 'checkbox', 'id' => "admin_checkbox_".$affiliateRequest['AffiliateRequest']['id'], 'label' => false, 'class' => $status_class.' js-checkbox-list')); ?></td>
			<td class="actions dl">
				<div class="action-block">
                        <span class="action-information-block">
                            <span class="action-left-block">&nbsp;&nbsp;</span>
                                <span class="action-center-block">
                                    <span class="action-info">
                                      <?php echo __l('Actions'); ?>                                   </span>
                                </span>
                            </span>
                            <div class="action-inner-block">
                            <div class="action-inner-left-block">
                                <ul class="action-link clearfix">
								<li>
		<span><?php echo $this->Html->link(__l('Edit'), array('action' => 'edit', $affiliateRequest['AffiliateRequest']['id']), array('class' => 'edit js-edit', 'title' => __l('Edit')));?></span>
		</li>
		<li>
		<span><?php echo $this->Html->link(__l('Delete'), array('action' => 'delete', $affiliateRequest['AffiliateRequest']['id']), array('class' => 'delete js-delete', 'title' => __l('Delete')));?></span></li></ul>
		</div>
		<div class="action-bottom-block"></div>
		</div></div></td>
		<td class="dl"><?php echo $this->Html->link($this->Html->cText($affiliateRequest['User']['username']), array('controller'=> 'users', 'action'=>'view', $affiliateRequest['User']['username'], 'admin' => false), array('escape' => false));?></td>
		<td class="dl"><?php echo $this->Html->cText($affiliateRequest['AffiliateRequest']['site_name']);?></td>
		<td class="dl">
		  <?php echo $this->Html->link($affiliateRequest['AffiliateRequest']['site_url'], $affiliateRequest['AffiliateRequest']['site_url']);?>
		</td>
		<td class="dl"><?php echo $this->Html->cText($affiliateRequest['SiteCategory']['name']);?></td>
		<td class="dl"><?php echo $this->Html->cText($affiliateRequest['AffiliateRequest']['why_do_you_want_affiliate']);?></td>
		
		<?PHP
		  if($affiliateRequest['AffiliateRequest']['is_web_site_marketing']):			
			$td_class = 'admin-status-1';
		 else:			
			$td_class = 'admin-status-0';
		endif;
		?>
		
		<td class="<?PHP echo $td_class; ?>"><?php echo $this->Html->cBool($affiliateRequest['AffiliateRequest']['is_web_site_marketing']);?></td>
		
		<?PHP
		  if($affiliateRequest['AffiliateRequest']['is_search_engine_marketing']):			
			$td_class = 'admin-status-1';
		 else:			
			$td_class = 'admin-status-0';
		endif;
		?>
		
		<td class="<?PHP echo $td_class; ?>"><?php echo $this->Html->cBool($affiliateRequest['AffiliateRequest']['is_search_engine_marketing']);?></td>
		
		<?PHP
		  if($affiliateRequest['AffiliateRequest']['is_email_marketing']):			
			$td_class = 'admin-status-1';
		 else:			
			$td_class = 'admin-status-0';
		endif;
		?>
		
		<td class="<?PHP echo $td_class; ?>"><?php echo $this->Html->cBool($affiliateRequest['AffiliateRequest']['is_email_marketing']);?></td>
        <td class="dc"><?php echo $this->Html->cText($affiliateRequest['AffiliateRequest']['special_promotional_method'],false);?></td>
		<td class="dc">
		   <span class="afflicate-request-status-<?PHP echo $affiliateRequest['AffiliateRequest']['is_approved']; ?>">  
			<?php if($affiliateRequest['AffiliateRequest']['is_approved'] == 0){
					echo __l('Waiting for Approval');
				  } else if($affiliateRequest['AffiliateRequest']['is_approved'] == 1){
				  	echo __l('Approved');
				  } else if($affiliateRequest['AffiliateRequest']['is_approved'] == 2){
				  	echo __l('Rejected');
				  }
		    ?>
		  </span>		   
		</td>
	</tr>
<?php
    endforeach;
else:
?>
	<tr>
		<td colspan="16" class="notice"><?php echo __l('No Affiliate Requests available');?></td>
	</tr>
<?php
endif;
?>
</table>

<?php
if (!empty($affiliateRequests)) :
        ?>
        <div class="clearfix">
        <div class="admin-select-block grid_left">
            <?php echo __l('Select:'); ?>
            <?php echo $this->Html->link(__l('All'), '#', array('class' => 'js-admin-select-all','title' => __l('All'))); ?>
            <?php echo $this->Html->link(__l('None'), '#', array('class' => 'js-admin-select-none','title' => __l('None'))); ?>
            <?php echo $this->Html->link(__l('Disapprove'), '#', array('class' => 'js-admin-select-pending', 'title' => __l('Disapprove'))); ?>
		    <?php echo $this->Html->link(__l('Approve'), '#', array('class' => 'js-admin-select-approved', 'title' => __l('Approve'))); ?>
      </div>
        <div class="admin-checkbox-button grid_4 grid_left">
            <?php echo $this->Form->input('more_action_id', array('class' => 'js-admin-index-autosubmit', 'label' => false, 'empty' => __l('-- More actions --'))); ?>
        </div>
        <div class="js-pagination grid_right">
            <?php echo $this->element('paging_links'); ?>
        </div>
            
        <div class="hide">
            <?php echo $this->Form->submit(__l('Submit'));  ?>
        </div>
        </div>
        <?php
    endif;
    echo $this->Form->end();
    ?>
</div>